Stochastic Differential Equation (SDE)

A Stochastic Differential Equation (SDE) is a differential equation in which one or more terms is a stochastic process, resulting in a solution that is itself a stochastic process. SDEs are used to model systems with random fluctuations and are fundamental to [[Diffusion Model|Diffusion Models]], financial mathematics, and physics.


1. Core Concept

1.1 From ODE to SDE

Ordinary Differential Equation (ODE):

dxdt=f(t,x)

Stochastic Differential Equation (SDE):

dxt=f(t,xt)dt+g(t,xt)dWt

The key difference is the addition of the stochastic term g(t,xt)dWt , where Wt is a [[Wiener Process|Wiener Process]].

[!NOTE] Key Insight
While ODEs describe deterministic evolution, SDEs incorporate random noise, making them suitable for modeling real-world systems with uncertainty.

1.2 Components of SDE

Component Notation Role
Drift coefficient f(t,xt) or μ(t,xt) Deterministic trend
Diffusion coefficient g(t,xt) or σ(t,xt) Noise intensity
**[[Wiener Process Wiener Process]]** Wt or Bt
State variable xt or Xt System state

2. Mathematical Foundation

2.1 Itô Interpretation

The SDE is interpreted as an integral equation:

xt=x0+0tf(s,xs)ds+0tg(s,xs)dWs

where the second integral is an [[Itô Integral|Itô integral]].

2.2 Itô’s Lemma

Theorem: For an Itô process:

dxt=μtdt+σtdWt

and a twice-differentiable function h(t,x) , we have:

dh(t,xt)=(ht+μthx+12σt22hx2)dt+σthxdWt

[!WARNING] Itô vs Stratonovich
The extra term 12σt22hx2 is unique to Itô calculus and arises from the non-zero quadratic variation of [[Wiener Process|Wiener process]]. This term does not appear in classical calculus.

2.3 Itô’s Lemma in Multiple Dimensions

For xtRn with SDE:

dxt=μtdt+σtdWt

and function h(t,x):R×RnRm :

dh=(ht+iμtihxi+12i,j(σtσt)ij2hxixj)dt+ihxiσtidWt

3. Common Types of SDEs

3.1 Linear SDE

dxt=(a(t)xt+b(t))dt+(c(t)xt+d(t))dWt

Solution method: Use integrating factor or variation of constants.

3.2 Geometric [[Wiener Process|Brownian Motion]]

dSt=μStdt+σStdWt

Solution (using Itô’s Lemma on logSt ):

St=S0exp((μσ22)t+σWt)

Application: Stock price modeling (Black-Scholes).

3.3 Ornstein-Uhlenbeck Process

dxt=θxtdt+σdWt

Solution:

xt=x0eθt+σ0teθ(ts)dWs

Properties:

  • Mean-reverting to zero
  • Stationary distribution: xN(0,σ22θ)
  • Used in interest rate models (Vasicek model)

3.4 Variance-Preserving SDE (VP-SDE)

dxt=12β(t)xtdt+β(t)dWt

Properties:

  • Marginal distribution: xtx0N(e120tβ(s)dsx0,(1e0tβ(s)ds)I)
  • Preserves variance in [0,1]
  • Primary choice for [[Diffusion Model|Diffusion Models]]

3.5 Variance-Exploding SDE (VE-SDE)

dxt=dσ2(t)dtdWt

Properties:

  • Variance grows with time: Var(xt)=σ2(t)
  • No drift term
  • Alternative formulation for diffusion models

4. Solving SDEs

4.1 Analytical Solutions

Some SDEs have closed-form solutions:

SDE Solution Method
dxt=μdt+σdWt xt=x0+μt+σWt Direct integration
dSt=μStdt+σStdWt St=S0e(μσ2/2)t+σWt Itô’s Lemma
dxt=θxtdt+σdWt xt=x0eθt+σ0teθ(ts)dWs Integrating factor

4.2 Numerical Methods

Euler-Maruyama Method

Simplest discretization:

xt+Δt=xt+f(t,xt)Δt+g(t,xt)Δtϵ,ϵN(0,1)

Convergence: Strong order 0.5, weak order 1.0

Milstein Method

Higher-order method:

xt+Δt=xt+fΔt+gΔW+12ggx((ΔW)2Δt)

Convergence: Strong order 1.0

1
2
3
4
5
6
7
8
9
10
11
12
# Pseudocode: Euler-Maruyama Method
def euler_maruyama(f, g, x0, T, N):
dt = T / N
x = x0
path = [x0]

for i in range(N):
dW = sqrt(dt) * sample_normal(0, 1)
x = x + f(t, x) * dt + g(t, x) * dW
path.append(x)

return path

5. Fokker-Planck Equation

5.1 Forward Kolmogorov Equation

The probability density p(t,x) of the SDE solution satisfies:

pt=x[f(t,x)p]+122x2[g(t,x)2p]

This is the Fokker-Planck equation (or forward Kolmogorov equation).

5.2 Stationary Distribution

For time-homogeneous SDE dxt=f(xt)dt+g(xt)dWt , the stationary distribution p(x) satisfies:

0=ddx[f(x)p(x)]+12d2dx2[g(x)2p(x)]

Solution (for g(x)=σ constant):

p(x)exp(2σ2xf(y)dy)

5.3 Connection to [[Probability Flow ODE|Probability Flow ODE]]

The Fokker-Planck equation can be written as a continuity equation:

pt=(vp)

where the velocity field v defines the [[Probability Flow ODE]] with the same marginals.


6. SDEs in Diffusion Models

6.1 Forward Process

In diffusion models, data x0 is gradually corrupted by noise:

dxt=f(t)xtdt+g(t)dWt

Common choices:

SDE Type f(t) g(t) Marginal
VP-SDE 12β(t) β(t) N(e12βx0,(1eβ)I)
VE-SDE 0 β(t) N(x0,0tβ(s)dsI)
Sub-Variance β(t) 2β(t) Interpolates between VP and VE

6.2 Reverse Process

The time-reversal of an SDE (Anderson, 1982):

dxt=[f(t)xtg(t)2xlogpt(x)]dt+g(t)dW¯t

where:

  • W¯t is reverse-time [[Wiener Process|Wiener process]]
  • xlogpt(x) is the [[Score Function|score function]]
  • Must be solved backward from t=T to t=0

6.3 Score Matching

Learn the score function with neural network sθ(x,t)xlogpt(x) :

Objective:

L(θ)=Et,x0,xt[sθ(xt,t)xtlogp(xtx0)2]

For VP-SDE:

xtlogp(xtx0)=xte120tβ(s)dsx01e0tβ(s)ds

7. Beyond SDE: ODE Equivalence and Fast Sampling

7.1 From SDE to [[Probability Flow ODE]]

The reverse SDE can be deterministically transformed into an ODE with identical marginals:

dx=[f(t)x12g(t)2xlogpt(x)]dt

This [[Probability Flow ODE]] enables:

  • Deterministic sampling (same noise → same output)
  • Exact likelihood computation via instantaneous change of variables
  • Inversion of real data to latent space

7.2 Fast SDE Sampling Methods

Method Type Steps Key Idea
DDPM SDE 1000 Original Markov chain
[[DDIM]] Non-Markovian 50-100 Relaxes Markov assumption
[[DPM-Solver]] ODE 10-20 Semi-linear structure exploitation
Predictor-Corrector SDE+ODE 20-50 Langevin refinement steps

7.3 Numerical Stability in SDE Solvers

Key challenges for diffusion model SDEs:

  1. Stiffness near t=0 : VP-SDE becomes very stiff

    • Fix: Non-uniform time discretization, more steps near t=0
  2. Score function explosion: As t0 , the score xlogpt(x) diverges

    • Fix: Use ϵ -prediction instead of direct score prediction
  3. Discretization error accumulation: Euler-Maruyama error propagates

    • Fix: Higher-order methods (Milstein, [[DPM-Solver]])
  4. SDE vs ODE trade-off:

    • SDE: Better quality (injecting fresh noise), slower
    • ODE: Faster, deterministic, better for inversion

8. Existence and Uniqueness

8.1 Lipschitz Conditions

Theorem: If f(t,x) and g(t,x) satisfy:

  1. Lipschitz condition: |f(t,x)f(t,y)|+|g(t,x)g(t,y)|K|xy|
  2. Linear growth: |f(t,x)|2+|g(t,x)|2K(1+|x|2)

then the SDE has a unique strong solution.

8.2 Weak vs Strong Solutions

Type Definition Requirement
Strong solution xt adapted to filtration of Wt Fixed probability space
Weak solution Existence of (xt,Wt) jointly Distribution equivalence

9. Girsanov Theorem

9.1 Change of Measure

Theorem: Under suitable conditions, we can change measure PQ to eliminate drift:

If dxt=μtdt+σtdWtP , then under Q :

dxt=σtdWtQ

where dWtQ=dWtP+μtσtdt .

9.2 Applications

  • Risk-neutral pricing in finance
  • Importance sampling for variance reduction
  • Likelihood ratio computation in diffusion models

10. Core Formula Cards

[!QUOTE] General SDE

dxt=f(t,xt)dt+g(t,xt)dWt

[!QUOTE] Itô’s Lemma

dh=(ht+fhx+12g22hx2)dt+ghxdWt

[!QUOTE] Geometric [[Wiener Process|Brownian Motion]]

dSt=μStdt+σStdWt

[!QUOTE] Ornstein-Uhlenbeck Process

dxt=θxtdt+σdWt

[!QUOTE] VP-SDE (Diffusion Models)

dxt=12β(t)xtdt+β(t)dWt

[!QUOTE] Reverse-Time SDE

dxt=[f(t)xtg(t)2xlogpt(x)]dt+g(t)dW¯t

[!QUOTE] Fokker-Planck Equation

pt=x[fp]+122x2[g2p]

[!QUOTE] Euler-Maruyama Discretization

xt+Δt=xt+f(t,xt)Δt+g(t,xt)Δtϵ

  • [[Wiener Process|Wiener Process]]
  • [[Itô Integral]]
  • [[Itô’s Lemma]]
  • [[Martingale]]
  • [[Diffusion Model]]
  • [[Probability Flow ODE]]
  • [[Score Function]]
  • [[DDIM]]
  • [[DPM-Solver]]
  • [[Flow Matching]]
  • [[Markov Process]]
  • [[Fokker-Planck Equation]]
  • [[Kolmogorov Equations]]
  • [[Langevin Dynamics]]
  • [[Stochastic Process]]
  • [[Brownian Motion]]

Dataview Query

1
2
3
LIST
FROM #sde OR #stochastic_calculus
SORT file.ctime DESC

References

  • Book: Stochastic Differential Equations - Bernt Øksendal
  • Book: [[Wiener Process|Brownian Motion]] and Stochastic Calculus - Karatzas & Shreve
  • Paper: Score-Based Generative Modeling through SDEs (Song et al., 2021)
  • Paper: Maximum Likelihood Training of Score-Based Diffusion Models (Song et al., 2021)
  • Course: MIT 18.S096 Topics in Mathematics with Applications in Finance
  • Course: CS236 Deep Generative Models (Stanford)